import { computed } from "vue";

export default fn => {
  const map = new Map();
  return (...arg) => {
    const key = JSON.stringify(arg);
    if (map.has(key)) {
      return map.get(key);
    }
    const result = computed(() => {
      return fn(...arg);
    });
    map.set(key, result);
    return result;
  };
};
